package com.atguigu.xiaozhi.tools;

import com.atguigu.xiaozhi.assistant.SeparateChatAssistant;
import com.atguigu.xiaozhi.bean.ChatForm;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.agent.tool.ToolMemoryId;
import dev.langchain4j.service.MemoryId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author kkdulx
 * @date 2025/10/27
 */

@Component
public class CalculatorTools {

    @Tool(name = "加法1", value = "当参数为正数的时候调用方法")
    double sum1(double a, double b) {
        System.out.println("调用加法运算 sum1");
        return a + b;
    }

    @Tool(name = "加法2", value = "当参数为负数的时候调用方法")
    double sum2(double a, double b) {
        System.out.println("调用加法运算 sum2");
        return a + b;
    }

    @Tool(name = "平方根")
    double squareRoot(double x) {
        System.out.println("调用平方根运算");
        return Math.sqrt(x);
    }

    @Tool(name = "减法", value = "当操作数1（也就是a）是正数，并且操作数2（也就是b）是负数的时候调用此方法")
    double sub(@P(value = "操作数1") double a, @P(value = "操作数2") double b, @ToolMemoryId int memoryId){
        System.out.println("调用减法运算，聊天会话的id："+ memoryId);
        return a - b;
    }

}
